import 'dart:math';
import 'dart:ui';
import 'package:flame/sprite.dart';

import 'ballGame.dart';

class Backyard {
  final MyGame game;
  Sprite bgSprite;
  List<Sprite> bgSprites;

  Rect bgRect;

  Backyard(this.game) {
    bgSprites = [
      Sprite('files/ball/backyard.png',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio),
      Sprite('files/ball/backyard-1.png',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio),
      Sprite('files/ball/backyard-2.jpg',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio),
      Sprite('files/ball/backyard-3.jpg',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio),
      Sprite('files/ball/backyard-4.png',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio),
      Sprite('files/ball/backyard-5.jpg',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio),
      Sprite('files/ball/backyard-6.jpg',
          width: game.screenSize.width*window.devicePixelRatio, height: game.screenSize.height*window.devicePixelRatio)
    ];

    bgSprite = bgSprites[Random().nextInt(bgSprites.length)];

    bgRect = Rect.fromLTWH(
      0,
      0,
      game.screenSize .width,
      game.screenSize.height,
    );
  }

  void randomBackyard() {
    bgSprite.image = bgSprites[Random().nextInt(bgSprites.length)].image;
  }

  void render(Canvas c) {
    bgSprite.renderRect(c, bgRect);
  }

  void update(double t) {}
}
